package com.company;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 * @author jrue
 * @version 1.0
 * @date 2020/3/17 19:15
 */
public class Main01 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 0) {
            System.out.println("0");
        }
        if (n == 1) {
            System.out.println("1");
        }
        ArrayList<Box> boxes = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            Box box = new Box();
            box.x = x;
            box.y = y;
            boxes.add(box);
        }
        Collections.sort(boxes, (o1, o2) -> {
            if (o1.x != o2.x) return o1.x - o2.x;
            return o1.y - o2.y;
        });

        long[] dp = new long[boxes.size()];
        for (int i = 0; i < boxes.size(); i++) {
            Box thisBox = boxes.get(i);
            int count =0;
            for (int j = i + 1; j < boxes.size(); j++) {
                Box node = boxes.get(j);
                if (node.x > thisBox.x && node.y > thisBox.y) {
                    count++;
                    thisBox = node;
                }
            }
            dp[i] = count;
        }
        long max = 0;
        for (int i = 0; i < dp.length; i++) {
            max = Math.max(dp[i],max);
        }
        System.out.println(max + 1);
    }

}
class Box {
    int x,y;
}